<?xml version="1.0" encoding="utf-8"?>
<!--
    Copyright (C) 2010 Ethan Gruber
    EADitor: http://code.google.com/p/eaditor/
    Apache License 2.0: http://code.google.com/p/eaditor/    
-->
<xhtml:html xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ev="http://www.w3.org/2001/xml-events"
	xmlns:xxforms="http://orbeon.org/oxf/xml/xforms" xmlns:widget="http://orbeon.org/oxf/xml/widget" xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:fr="http://orbeon.org/oxf/xml/form-runner"
	xmlns:exist="http://exist.sourceforge.net/NS/exist" xmlns:ead="urn:isbn:1-931666-22-9" xmlns:xxi="http://orbeon.org/oxf/xml/xinclude" xmlns:eaditor="http://code.google.com/p/eaditor/">
	<xhtml:head>
		<xhtml:title>EADitor: Edit Settings</xhtml:title>
		<xhtml:link rel="stylesheet" type="text/css" href="/apps/eaditor/css/grids-min.css"/>
		<xhtml:link rel="stylesheet" type="text/css" href="/apps/eaditor/css/reset-fonts-grids.css"/>
		<xhtml:link rel="stylesheet" type="text/css" href="/apps/eaditor/css/base-min.css"/>
		<xhtml:link rel="stylesheet" type="text/css" href="/apps/eaditor/css/fonts-min.css"/>

		<!-- EADitor styling -->
		<xhtml:link rel="stylesheet" href="/apps/eaditor/css/style.css"/>
		<xhtml:link rel="stylesheet" href="/apps/eaditor/css/themes/smoothness.css"/>

		<xhtml:script type="text/javascript" src="/apps/eaditor/javascript/jquery-1.4.2.min.js"/>
		<xhtml:script type="text/javascript" src="/apps/eaditor/javascript/menu.js"/>

		<xforms:model>
			<xs:schema> 	
				<xs:simpleType name="emailAddress"> 
					<xs:restriction base="xs:string"> 
						<xs:pattern value="[^@]+@[^\.]+\..+"/> 
					</xs:restriction> 
				</xs:simpleType> 
			</xs:schema>
			
			
			<!-- exist URL is stored in an XML file -->
			<xforms:instance id="exist-url">
				<xi:include href="exist-url.xml"/>
			</xforms:instance>

			<xforms:instance id="config">
				<config xmlns=""/>
			</xforms:instance>

			<xforms:instance id="status">
				<status/>
			</xforms:instance>

			<xforms:instance id="control-instance">
				<control xmlns="">
					<api-key-accepted/>
					<save-trigger/>
				</control>
			</xforms:instance>

			<xforms:instance id="flickr-response">
				<rsp xmlns=""/>
			</xforms:instance>

			<!-- jQuery UI themes -->
			<xforms:instance id="jquery-ui-themes">
				<themes xmlns="">
					<theme>base</theme>
					<theme>black-tie</theme>
					<theme>blitzer</theme>
					<theme>cupertino</theme>
					<theme>dark-hive</theme>
					<theme>dot-luv</theme>
					<theme>eggplant</theme>
					<theme>excite-bike</theme>
					<theme>flick</theme>
					<theme>hot-sneaks</theme>
					<theme>humanity</theme>
					<theme>le-frog</theme>
					<theme>mint-choc</theme>
					<theme>overcast</theme>
					<theme>pepper-grinder</theme>
					<theme>redmond</theme>
					<theme>smoothness</theme>
					<theme>south-street</theme>
					<theme>start</theme>
					<theme>sunny</theme>
					<theme>swanky-purse</theme>
					<theme>trontastic</theme>
					<theme>ui-darkness</theme>
					<theme>ui-lightness</theme>
					<theme>vader</theme>
				</themes>
			</xforms:instance>
			
			<!-- OAI-PMH fields -->
			<xforms:instance id="repositoryName-template">
				<repositoryName xmlns=""/>
			</xforms:instance>

			<xforms:instance id="adminEmail-template">
				<adminEmail xmlns=""/>
			</xforms:instance>

			<xforms:bind nodeset="instance('config')">
				<xforms:bind nodeset="title" required="true()"/>
				<xforms:bind nodeset="solr_published" required="true()"/>
				<xforms:bind nodeset="solr_unpublished" required="true()"/>
				<xforms:bind nodeset="solr_vocabularies" required="true()"/>
				<xforms:bind nodeset="theme/jquery_ui_theme" required="true()"/>
				<xforms:bind nodeset="oai-pmh">
					<xforms:bind nodeset="@active" type="xs:boolean"/>
					<xforms:bind nodeset="repositoryName" constraint="string-length(.) &gt; 0"/>
					<xforms:bind nodeset="adminEmail" type="emailAddress"/>
				</xforms:bind>
			</xforms:bind>

			<xforms:bind nodeset="instance('control-instance')/save-trigger" readonly="instance('control-instance')/api-key-accepted = 'false'"/>
			<xforms:bind id="visual-tab" nodeset="instance('config')/theme"/>

			<!-- submissions -->
			<xforms:submission id="load-config" serialization="none" method="get" action="{instance('exist-url')}eaditor/config.xml" replace="instance" instance="config">
				<xforms:message ev:event="xforms-submit-error" level="modal">Unable to load EADitor config. Is eXist operational?</xforms:message>
			</xforms:submission>

			<xforms:submission id="save-config" ref="instance('config')" action="{instance('exist-url')}eaditor/config.xml" method="put" replace="none" xxforms:username="admin" xxforms:password="">
				<xforms:message ev:event="xforms-submit-error" level="modal">Error Saving Config.</xforms:message>
				<xforms:setvalue ref="instance('status')" ev:event="xforms-submit-done">EADitor configuration saved.</xforms:setvalue>
			</xforms:submission>

			<!-- test for flickr echo -->
			<xforms:submission id="test-for-echo" serialization="none" method="get"
				action="http://api.flickr.com/services/rest/?method=flickr.test.echo&amp;api_key={instance('config')/flickr_api_key}" replace="instance" instance="flickr-response">
				<xforms:message ev:event="xforms-submit-error" level="modal">Error querying flickr. Please check internet connection.</xforms:message>
				<xforms:action ev:event="xforms-submit-done">
					<!-- set readonly for save button if the api key is a string and failed -->
					<xforms:setvalue ref="instance('control-instance')/api-key-accepted" if="not(instance('flickr-response')/@stat = 'ok') and string-length(instance('config')/flickr_api_key) &gt; 0"
						value="'false'"/>

					<!-- activate button if the api key is okay or blank -->
					<xforms:setvalue ref="instance('control-instance')/api-key-accepted" if="instance('flickr-response')/@stat = 'ok' or string-length(instance('config')/flickr_api_key) = 0"
						value="'true'"/>
				</xforms:action>
			</xforms:submission>

			<!-- load eaditor config file on xforms construction -->
			<xforms:action ev:event="xforms-model-construct-done">
				<xforms:send submission="load-config"/>
			</xforms:action>
		</xforms:model>
	</xhtml:head>

	<xhtml:body class="yui-skin-sam">
		<xhtml:div id="doc4">
			<!-- header -->
			<xxforms:variable name="display_path">../../</xxforms:variable>
			<xi:include href="header-admin.xml"/>

			<xhtml:div id="bd">
				<xhtml:div id="form">
					<xforms:group ref="instance('status')/text()">
						<xhtml:div class="success">
							<xforms:output ref="instance('status')"/>
						</xhtml:div>
					</xforms:group>
					<xhtml:p>
						<xhtml:a href="../">&lt; Return</xhtml:a>
					</xhtml:p>
					<xhtml:div class="submission">
						<xforms:trigger ref="instance('control-instance')/save-trigger" appearance="minimal">
							<xforms:label><img src="/apps/eaditor/images/save.gif" alt="Save"/> Save</xforms:label>
							<xforms:send ev:event="DOMActivate" submission="save-config"/>
						</xforms:trigger>
					</xhtml:div>


					<xhtml:h1>EADitor Settings</xhtml:h1>

					<fr:tabview>
						<!--**************************************** CONFIGURATION **********************************-->
						<fr:tab id="configure-tab">
							<fr:label>Configuration</fr:label>
							<xhtml:h1>Configuration</xhtml:h1>
							<xforms:group ref="instance('config')">
								<xhtml:div class="section">
									<xhtml:h2>Titles and URLs</xhtml:h2>
									<xhtml:div>
										<xforms:input ref="title">
											<xforms:label>Title</xforms:label>
											<xforms:alert>Required</xforms:alert>
										</xforms:input>
										<xhtml:p>The title of the site to be displayed in all web page titles and citations in PDF files.</xhtml:p>
									</xhtml:div>
									<xhtml:div>
										<xforms:input ref="banner_text">
											<xforms:label>Banner Text</xforms:label>
											<xforms:alert>Required</xforms:alert>
										</xforms:input>
										<xhtml:p>Appears in the header banner. For more sophisticated control, edit header.xsl.</xhtml:p>
									</xhtml:div>
									<xhtml:div>
										<xforms:input ref="url">
											<xforms:label>URL</xforms:label>
											<xforms:alert>Required</xforms:alert>
										</xforms:input>
										<xhtml:p>Public URL of the site. This is used for forming links to the XML and HTML versions of finding aids, should the public and private aspects of EADitor
											be contained on different servers.</xhtml:p>
									</xhtml:div>
									<!--<xforms:group ref="banner_image">
										<numishare:banner-upload/>
									</xforms:group>-->
								</xhtml:div>
								<xhtml:div class="section">
									<xforms:group ref="oai-pmh">
										<xhtml:h2>OAI-PMH</xhtml:h2>
										<xhtml:p>Activate OAI-PMH to enable a link on the index page. The feed validates to OAI protocal at the YYYY-MM-DD granularity. <xhtml:b>Important: </xhtml:b>
											Validation only passes if EADitor is run on an external server (i.e., not localhost) which uses Apache proxying to make the :8080 Tomcat port. The OAI
											unique identifier is derived from the URL on this settings page.</xhtml:p>
										<xhtml:div>
											<xforms:input ref="@active" id="oai-active">
												<xforms:label>Active</xforms:label>
												<!-- insert required OAI-PMH fields on 'active', else delete them -->
												<xforms:action ev:event="xforms-value-changed">
													<xforms:action if="parent::node()/@active='true'">
														<xforms:insert context="parent::node()" origin="instance('repositoryName-template')"/>
														<xforms:insert context="parent::node()" origin="instance('adminEmail-template')"/>
													</xforms:action>
													<xforms:action if="parent::node()/@active='false'">
														<xforms:delete nodeset="parent::node()/*"/>												
													</xforms:action>
												</xforms:action>												
											</xforms:input>
										</xhtml:div>
										<xhtml:div>
											<xforms:input ref="repositoryName">
												<xforms:label>Repository Name</xforms:label>
												<xforms:alert>Required</xforms:alert>
											</xforms:input>
										</xhtml:div>
										<xhtml:div>
											<xforms:input ref="adminEmail">
												<xforms:label>Administrator Email</xforms:label>
												<xforms:alert>Required</xforms:alert>
											</xforms:input>
										</xhtml:div>
									</xforms:group>
								</xhtml:div>
								<xhtml:div class="section">
									<xhtml:h2>flickr API Key</xhtml:h2>
									<xforms:group ref=".[instance('flickr-response')/@stat='fail' and string-length(flickr_api_key) &gt; 0]">
										<xhtml:div class="ui-widget">
											<xhtml:div class="ui-state-error ui-corner-all">
												<xhtml:p>
													<xhtml:span class="ui-icon ui-icon-alert" style="float: left; margin-right: 0.3em;"/>
													<xhtml:strong>Alert:</xhtml:strong>
													<xforms:output ref="instance('flickr-response')/err/@msg"/>
												</xhtml:p>
											</xhtml:div>
										</xhtml:div>
									</xforms:group>
									<xhtml:div>
										<xforms:input ref="flickr_api_key" incremental="true">
											<xforms:label>flickr API Key</xforms:label>
											<xforms:send submission="test-for-echo" ev:event="xforms-value-changed"/>
										</xforms:input>
										<xhtml:p>A <a href="http://www.flickr.com/services/api/misc.api_keys.html">flickr API key</a> is required in order to take advantage of flickr image linking in
											Numishare.</xhtml:p>
									</xhtml:div>
								</xhtml:div>
							</xforms:group>
						</fr:tab>
						<!--**************************************** THEMES AND LAYOUT **********************************-->
						<fr:tab bind="visual-tab">
							<fr:label>Themes and Layout</fr:label>
							<xhtml:div class="section">
								<xhtml:h1>Layout</xhtml:h1>
								<xhtml:h2>Browse Page</xhtml:h2>
								<xhtml:p>Two page layouts are available for the browse section. Facets may occur either in a left or right-aligned column. Output fields can also be selected from the
									list below and ordered. Keep in mind that selecting many fields may result in a cumbersome user experience. Thumbnail images may be aligned either to the left or
									right of the record content.</xhtml:p>

								<xforms:group ref="layouts/results">
									<xhtml:div class="subsection">
										<xhtml:h3>Facet Column Alignment</xhtml:h3>
										<xhtml:div>
											<xforms:select1 ref="yui_class">
												<xforms:label>Alignment</xforms:label>
												<xforms:item>
													<xforms:label>left</xforms:label>
													<xforms:value>yui-t2</xforms:value>
												</xforms:item>
												<xforms:item>
													<xforms:label>right</xforms:label>
													<xforms:value>yui-t5</xforms:value>
												</xforms:item>
											</xforms:select1>
										</xhtml:div>
									</xhtml:div>
									<xhtml:div class="subsection">
										<xhtml:h3>Result Documents</xhtml:h3>
										<xhtml:div>
											<xforms:select1 ref="image_location">
												<xforms:label>Thumbnail Alignment</xforms:label>
												<xforms:item>
													<xforms:label>left</xforms:label>
													<xforms:value>left</xforms:value>
												</xforms:item>
												<xforms:item>
													<xforms:label>right</xforms:label>
													<xforms:value>right</xforms:value>
												</xforms:item>
											</xforms:select1>
										</xhtml:div>
									</xhtml:div>
								</xforms:group>
							</xhtml:div>
							<xhtml:div class="section">
								<xhtml:h1>Theme</xhtml:h1>
								<xhtml:div>
									<xforms:select1 ref="jquery_ui_theme">
										<xforms:label>jQuery UI Theme</xforms:label>
										<xforms:alert>Required</xforms:alert>
										<xforms:itemset nodeset="instance('jquery-ui-themes')/theme">
											<xforms:label ref="."/>
											<xforms:value ref="."/>
										</xforms:itemset>
									</xforms:select1>
								</xhtml:div>
							</xhtml:div>
						</fr:tab>
						<!--**************************************** ADVANCED SETTINGS **********************************-->
						<fr:tab id="advanced">
							<fr:label>Advanced</fr:label>
							<xforms:group ref="instance('config')">
								<xhtml:h2>Advanced Settings</xhtml:h2>
								<xhtml:div class="section">
									<xhtml:p>
										<xhtml:b>Only change these options if Orbeon is run on a separate server.</xhtml:b>
									</xhtml:p>
									<xhtml:p>Changing these options to an inactive URL could break public display and web form functionality.</xhtml:p>
									<xhtml:div class="subsection">
										<xhtml:h3>Solr URLs</xhtml:h3>
										<xhtml:div>
											<xforms:input ref="solr_published">
												<xforms:label>Published</xforms:label>
												<xforms:alert>Required</xforms:alert>
											</xforms:input>
										</xhtml:div>
										<xhtml:div>
											<xforms:input ref="solr_unpublished">
												<xforms:label>Unpublished</xforms:label>
												<xforms:alert>Required</xforms:alert>
											</xforms:input>
										</xhtml:div>
										<xhtml:div>
											<xforms:input ref="solr_vocabularies">
												<xforms:label>Vocabularies</xforms:label>
												<xforms:alert>Required</xforms:alert>
											</xforms:input>
										</xhtml:div>
									</xhtml:div>
								</xhtml:div>
							</xforms:group>
						</fr:tab>
					</fr:tabview>
				</xhtml:div>

				<!--<widget:xforms-instance-inspector id="orbeon-xforms-inspector" xmlns:widget="http://orbeon.org/oxf/xml/widget"/>-->
			</xhtml:div>

			<!-- footer -->
			<xi:include href="xslt/footer.xml"/>
		</xhtml:div>
	</xhtml:body>
</xhtml:html>
